<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/userRole.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/style_table.css}"/>
</head>
<style type="text/css">
    .form-horizontal {
        margin: 0;
        padding: 20px 50px
    }

    .form-group label {
        margin-top: 7px
    }

</style>
<body>

<form id="fm" class="form-horizontal"  novalidate>
    <div class="form-group">
        <label class="col-xs-3 control-label">姓 名:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="realName" id="realName" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">性 别:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="sex" id="sex" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">电 话:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="tel" id="tel" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">姓 名:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="realName2" id="realName2" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">性 别:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="sex2" id="sex2" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">电 话:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="tel2" id="tel2" class="form-control ">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">住 址:</label>
        <div class="col-xs-9">
            <input type="text" readonly="readonly" name="address" id="address" class="form-control ">
        </div>
    </div>

</form>

</body>
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/plugin/easyui/jquery.easyui.min.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layer/layer.js}"></script>
<script th:inline="javascript">

    $(function () {
        var postData = new Array();
        var parent1Id = sessionStorage.getItem("parent1Id");
        var parent2Id = sessionStorage.getItem("parent2Id");
        postData.parent1Id = parent1Id;
        postData.parent2Id = parent2Id;
        $.ajax({
            url: "/getParentsByParentId",
            type: "GET",
            data: {
                "parent1Id" : parent1Id,
                "parent2Id" : parent2Id
            },
            dataType: "json",
            headers: {'Content-Type': 'application/json'},
            success: function (data) {
                if (data.msg == 200) {
                    $("#realName").val(data.parentList[0].realName);
                    $("#sex").val(data.parentList[0].sex);
                    $("#tel").val(data.parentList[0].tel);
                    $("#address").val(data.parentList[0].address);
                    if(data.parentList.length == 2){
                        $("#realName2").val(data.parentList[1].realName);
                        $("#sex2").val(data.parentList[1].sex);
                        $("#tel2").val(data.parentList[1].tel);
                    }else {
                        $("#realName2").val("未添加");
                        $("#sex2").val("未添加");
                        $("#tel2").val("未添加");
                    }

                } else {
                    layer.msg(data.msg);
                }
            },
            error: function (error) {
                layer.msg("系统繁忙！");
                console.log(error);
            }
        });

    });
</script>
</html>